﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using AAA.Models;
using AAA.Db;
using AAA.Utils;

namespace AAA.Controllers
{
    public class HomeController : Controller
    {
        private readonly ILogger<HomeController> _logger;

        public HomeController(ILogger<HomeController> logger)
        {
            _logger = logger;
        }

        public IActionResult Index()
        {
            var db=new DemoDb();
            /* var p=new Person{
                PersonName="小明",
                IsActiced=true,
                IsDelected=false,
                DisplayOrder=0,
                CreatedTime=DateTime.Now,
                UpdatedTime=DateTime.Now,
                CreatorId=0
            };
            db.Person.Add(p);
            //db.SaveChanges();

            var p1=db.Person.FirstOrDefault(x=>x.ID==2);
            db.Person.Remove(p1);
            db.SaveChanges(); */


            /* var pp=db.Person.FirstOrDefault();
            //var pp=db.Person.OrderBy(x=>x.ID).FirstOrDefault();
            pp.PersonName="小灰灰";
            pp.UpdatedTime=DateTime.Now;
            db.Person.Update(pp);
            db.SaveChanges(); */


            /* var pp=(from x in db.Person
                    where x.ID==1
                    select x).FirstOrDefault();
            pp.PersonName="小灰灰";
            pp.UpdatedTime=DateTime.Now;
            db.Person.Update(pp);
            db.SaveChanges(); */


            var p1=db.Person.Where(x=>x.ID==3);
            var ss="灰太狼";
            var vv=p1.where();
            var uu=ss.pp();



            return View();
        }

        public IActionResult Privacy()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}
